MYLIB=libloggerClient.a
PROGS=mySyslogd ${MYLIB} stressTester
CC=gcc
CFLAGS=-Wall -pedantic -g -std=c99 -D_GNU_SOURCE
LINKLIBRARY=-static -L. -lloggerClient -lpthread

all: ${PROGS}

fileLockHelper.o: fileLockHelper.c fileLockHelper.h
	${CC} ${CFLAGS} fileLockHelper.c -c -o fileLockHelper.o
	
sysLogger.o: sysLogger.c sysLogger.h
	${CC} ${CFLAGS} sysLogger.c -c
	 
clientLogger.o: clientLogger.c clientLogger.h
	${CC} ${CFLAGS} clientLogger.c -c 

errorLogging.o: errorLogging.c errorLogging.h
	${CC} ${CFLAGS} errorLogging.c -c
	
#create a static library that can be used by the client programs 
${MYLIB}: clientLogger.o fileLockHelper.o
	ar rcs ${MYLIB} clientLogger.o fileLockHelper.o

	
mySyslogd: mySyslogd.c sysLogger.o errorLogging.o fileLockHelper.o
	${CC} ${CFLAGS} mySyslogd.c sysLogger.o errorLogging.o fileLockHelper.o -o mySyslogd 
	
#compile the testing client program 	
stressTester: stressTester.c ${MYLIB}
	${CC} ${CFLAGS} stressTester.c -o $@ ${LINKLIBRARY}
	
.PHONY: clean

clean:
	rm -f ${PROGS} *.log *.o *.a *~ .swp ./mySyslogd
